package com.ruoyi.common.websocket;

import lombok.Data;

import java.io.Serializable;

/**
 * @author ab785
 * createTime: 2021-12-7.
 * description: 消息提示提示实体
 */
@Data
public class SocketMessageNotifyData implements Serializable {
    
    private static final long serialVersionUID = 1L;

    /**
     * 消息通知类型
     */
    public static class MessageType {
        /**
         * 成功消息
         */
        public static final String SUCCESS = "success";

        /**
         * 提示消息
         */
        public static final String INFO = "info";

        /**
         * 警告消息
         */
        public static final String WARNING = "warning";

        /**
         * 错误消息
         */
        public static final String ERROR = "error";
    }

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String message;

    /**
     * 消息内容
     */
    private String type = MessageType.INFO;

    /**
     * 是否显示关闭按钮
     */
    private boolean showClose = true;

    /**
     * 图标类名，若设置type,iconClass会被覆盖
     */
    private String iconClass;


    /**
     * 维持时间，0表示一直
     */
    private Long duration = 0L;

    /**
     * 是否允许使用html片段
     */
    private boolean dangerouslyUseHTMLString = true;


    /**
     * 成功消息
     */
    public static SocketMessageNotifyData createInstance(String type, String title, String message) {
        SocketMessageNotifyData d = new SocketMessageNotifyData();
        d.setTitle(title);
        d.setMessage(message);
        d.setType(type);
        return d;
    }

    /**
     * 成功消息
     */
    public static SocketMessageNotifyData createSuccessInstance(String title, String message) {
        SocketMessageNotifyData d = new SocketMessageNotifyData();
        d.setTitle(title);
        d.setMessage(message);
        d.setType(MessageType.SUCCESS);
        return d;
    }


    /**
     * 信息消息
     */
    public static SocketMessageNotifyData createInfoInstance(String title, String message) {
        SocketMessageNotifyData d = new SocketMessageNotifyData();
        d.setTitle(title);
        d.setMessage(message);
        d.setType(MessageType.INFO);
        return d;
    }


    /**
     * 警告消息
     */
    public static SocketMessageNotifyData createWarningInstance(String title, String message) {
        SocketMessageNotifyData d = new SocketMessageNotifyData();
        d.setTitle(title);
        d.setMessage(message);
        d.setType(MessageType.WARNING);
        return d;
    }

    /**
     * 错误消息
     */
    public static SocketMessageNotifyData createErrorInstance(String title, String message) {
        SocketMessageNotifyData d = new SocketMessageNotifyData();
        d.setTitle(title);
        d.setMessage(message);
        d.setType(MessageType.ERROR);
        return d;
    }
}
